home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / ncsat.cpt / Telnet2.5 final / tcpip / atalk.c next >
Encoding:
C/C++ Source or Header  |  1992-04-07  |  3.9 KB  |  162 lines

  1. #ifndef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    atalk.c
  6. *     by Gaige B. Paulsen
  7. ****************************************************************************
  8. *                                                                          *
  9. *      Uses    :                                                               *
  10. *      TCP/IP kernel for NCSA Telnet                                       *
  11. *      by Tim Krauskopf                                                    *
  12. *       with Macintosh code by Gaige B. Paulsen                                 *
  13. *                                                                          *
  14. *      National Center for Supercomputing Applications                     *
  15. *      152 Computing Applications Building                                 *
  16. *      605 E. Springfield Ave.                                             *
  17. *      Champaign, IL  61820                                                *
  18. *                                                                          *
  19. *                                                                          *
  20. ****************************************************************************
  21. *
  22. *    Appletalk init and shutdown (and utility) procs.    
  23. *
  24. *    Called by:
  25. *        dlayer.c
  26. *        mactools.c
  27. *        macutil.c
  28. */
  29.  
  30. #include <stdio.h>
  31.  
  32. #include <AppleTalk.h>
  33. #include <Dialogs.h>
  34. #include <Devices.h>
  35.  
  36. #include "protocol.h"
  37. #include "configrec.h"
  38. #include "data.h"
  39. #include "croft.h"
  40.  
  41. #include "mpw.h"
  42. #include "event.h"        /* BYU 2.4.15 */
  43. #include "maclook.h"
  44. #include "menu.h"
  45.  
  46. typedef struct {
  47.     char    node[26];
  48.     char    net[2];
  49. } ABusVarStruct, *ABusVarPtr, **ABusVarPtrPtr;
  50.  
  51. extern Listen();
  52. extern char *KIPnameptr;
  53. extern int EtherNet;            /* BYU 2.4.15 */
  54.  
  55. void getATaddress
  56.   (
  57.     int *hi,
  58.     int *low,
  59.     int *node
  60.   )
  61. {
  62.     ABusVarPtr ABusVars;
  63.     ABusVarPtrPtr ABusPtrPtr = (ABusVarPtrPtr) 0x2d8L;
  64.  
  65.     ABusVars = *ABusPtrPtr;
  66.     *hi = ABusVars->net[0];
  67.     *low = ABusVars->net[1];
  68.     *node = ABusVars->node[0];
  69.  
  70. }
  71.  
  72. int atopen
  73.   (
  74.     void
  75.   )
  76. {
  77.     short err;
  78.     short socket=72, refnum;        /* BYU 2.4.15 MPW */
  79.     ABusVarPtr ABusVars;
  80.     ABusVarPtrPtr ABusPtrPtr = (ABusVarPtrPtr) 0x2d8L;
  81.     char buffr[100];
  82.     DialogPtr dtemp;
  83.     MPPParamBlock pb;
  84.  
  85.     err = 0;
  86.  
  87. #ifndef MPW
  88.     err = opendriver("\P.MPP",&refnum);
  89. #else
  90.     err = OpenDriver("\P.MPP",&refnum);
  91. #endif MPW
  92.  
  93.     if (err == 0)
  94.       {
  95.         pb.DDPlistener = (Ptr) Listen;
  96.         pb.DDPsocket = socket;
  97.         err=POpenSkt(&pb, FALSE);
  98.       }
  99.     if (err != 0)
  100.       { 
  101.         sprintf(buffr,"Failed Appletalk initialization (%d)\015",err);    /* BYU 2.4.18 - changed \n to \015 */
  102.         putln(buffr);
  103. #ifndef MPW
  104.         if (err == -91)
  105.             paramtext(0L, 0L, 0L, "\PCouldn't install Listener");
  106.         else if (err == -97 || err == -98)
  107.             paramtext(0L, 0L, 0L,
  108.                 "\PYou forgot to turn on AppleTalk in the Chooser");
  109.         else if (err == -192)
  110.             paramtext(0L, 0L, 0L, "\PCouldn╒t find ╘atpl╒ resource");
  111.         else
  112.             paramtext(0L, 0L, 0L, "\PUnknown Error");
  113. #else
  114.         if (err == -91)
  115.             paramtext(0L, 0L, 0L, "Couldn't install Listener");
  116.         else if (err == -97 || err == -98)
  117.             paramtext(0L, 0L, 0L,
  118.                 "You forgot to turn on AppleTalk in the Chooser");
  119.         else if (err == -192)
  120.             paramtext(0L, 0L, 0L, "Couldn╒t find ╘atpl╒ resource");
  121.         else
  122.             paramtext(0L, 0L, 0L, "Unknown Error");
  123. #endif MPW
  124.         dtemp = GetNewDialog(302, (Ptr) 0L, (WindowPtr) -1L);
  125. #if 1                                                            /* BYU 2.4.15 */
  126.         DrawDialog(dtemp);                                        /* BYU 2.4.15 */
  127.         WaitSeconds(5);                                            /* BYU 2.4.15 */
  128.         EtherNet = -100;                                        /* BYU 2.4.15 */
  129. #else                                                            /* BYU 2.4.15 */
  130.         ModalDialog(0L,&item);
  131. #endif                                                            /* BYU 2.4.15 */
  132.         DisposDialog(dtemp);
  133. /*        quit();                                                    /* BYU 2.4.15 */
  134.       }
  135.  
  136.     ABusVars = *ABusPtrPtr;
  137.     nnmyaddr[0] = ABusVars->net[0];
  138.     nnmyaddr[1] = ABusVars->net[1];
  139.     nnmyaddr[2] = ABusVars->node[0];
  140.     nnmyaddr[3] = 72;
  141.  
  142.     sprintf(buffr,"Net : %d,  Node : %d",*((unsigned short *)(&(ABusVars->net[0]))),(int)(ABusVars->node[0]));
  143.     putln(buffr);
  144.     return(0);
  145. }
  146.  
  147. int atclose
  148.   (
  149.     void
  150.   )
  151. {
  152.     MPPParamBlock pb;
  153.  
  154.     pb.DDPsocket=72;
  155.     PCloseSkt(&pb, FALSE);
  156.  
  157.     if (KIPnameptr)
  158.         KIPunregister();
  159.  
  160.     return(0);
  161. }
  162.